#!/bin/bash
da=`date +"%Y-%m-%d-%H-%M-%S"`
if [[ `/bin/uname -r` =~ "el5" ]];then
version=5
elif [[ `/bin/uname -r` =~ "el6" ]];then
version=6
elif [[ `/bin/uname -r` =~ "el7" ]];then
version=7
else
version='6'
fi

basearch=`/bin/uname -m`

echo "version:$version basearch:$basearch"
mv -f /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo-$da
mv -f /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo-$da


cat > /etc/yum.repos.d/centos-${version}.repo <<EOF

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-${version} - Base
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
baseurl=http://mirrors.aliyun.com/centos/${version}/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-${version}
#released updates 
[updates]
name=CentOS-${version} - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates
baseurl=http://mirrors.aliyun.com/centos/${version}/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-${version}
#additional packages that may be useful
[extras]
name=CentOS-${version} - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras
baseurl=http://mirrors.aliyun.com/centos/${version}/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-${version}
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-${version} - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=centosplus
baseurl=http://mirrors.aliyun.com/centos/${version}/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-${version}
#contrib - packages by Centos Users
[contrib]
name=CentOS-${version} - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=contrib
baseurl=http://mirrors.aliyun.com/centos/${version}/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-${version}

#EPEL
[epel]
name=Extra Packages for Enterprise Linux ${version} - $basearch
baseurl=http://mirrors.aliyun.com/epel/${version}/$basearch
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-${version}


EOF


yum clean all

yum -y groupinstall "Development Tools"
yum -y install openssl-devel vim wget net-tools htop lrzsz glibc-static kernel

git config --global credential.helper store


